import { setupAxios } from "@/http/axios/"
import router, { setupRouter } from "@/router"
import { setupAntd } from "@/setup/ant-design-vue"
import { setupAppstore } from "@/store"
import { createApp } from "vue"
import App from "./App"
import "./index.scss"
import { isDevMode, isUseMock } from "./utils/env"
const { setupMockServer } = require("../mock/index.js")

const app = createApp(App)
// UI
setupAntd(app)
// router
setupRouter(app)
// store
setupAppstore(app)

//axios
setupAxios(app)

//注册指令
app.directive("permission", {
  beforeMount(el, binding, vnode, prevVnode) {
    console.log(el, binding, vnode, prevVnode)
  }
})

// mount app
router.isReady().then(() => {
  app.mount("#app")
})

//现有appconfig不包含此属性
const config = app.config as any
config.devtools = true

if (isDevMode()) {
  // 性能调试
  app.config.performance = true
}

/**
 * mock server
 */
if (isDevMode() && isUseMock()) {
  setupMockServer()
}
